package g4p.styledtext;

import g4p_controls.GAlign;
import g4p_controls.GButton;
import g4p_controls.GEvent;
import g4p_controls.GLabel;
import g4p_controls.GPassword;
import g4p_controls.GTextField;
import processing.core.PApplet;

public class TestFontMetrics extends PApplet {
	
	GButton btn;
	GLabel lbl, lblPwd;
	GTextField txf;
	GPassword pwd;
	
	public void setup(){
		size(400,400);
		
		lbl = new GLabel(this, 10,10,280,20, "Peter Lager lives in Wales");
		btn = new GButton(this, 10,40,280,20, "Click me and see what happens");
		btn.setTextAlign(GAlign.LEFT, null);
		txf = new GTextField(this, 10,70,280,20);
		txf.setText("Peter lives in Wales");
		pwd = new GPassword(this, 10,100,280,20);
		lblPwd = new GLabel(this, 10,140,280,20);
		lblPwd.setTextAlign(GAlign.LEFT, null);
		lblPwd.setOpaque(true);
		
	}
	
	public void handleButtonEvents(GButton button, GEvent event) { 
		if(button == btn){
			btn.setText("Click me and see what happens" +millis());
			lbl.setText("Peter Lager lives in Wales");
			txf.setText("Peter lives in Wales");
		}
	}

	public void handlePasswordEvents(GPassword pwordControl, GEvent event) { 
		String pword = pwd.getPassword();
		lblPwd.setText(pword);
		System.out.println("Password length " + pword.length());
		System.out.print("#");
		for(int i = 0; i < pword.length(); i++){
			System.out.print(pword.charAt(i) + "#");			
		}
		System.out.println();
	}

	
	public void draw(){
		background(240);
	}
}
